package com.tech.zhidengxian.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tech.zhidengxian.mapper.SchoolMapper;
import com.tech.zhidengxian.model.dataobject.SchoolDO;
import com.tech.zhidengxian.model.dto.SchoolDTO;
import com.tech.zhidengxian.service.api.SchoolService;
import com.tech.zhidengxian.util.JacksonUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SchoolServiceImpl implements SchoolService {

    @Resource
    private SchoolMapper schoolMapper;


    @Override
    public List<SchoolDTO> selectListByName(String keyword) {
        List<SchoolDO> schoolDOS = schoolMapper.selectListByName(keyword);
        List<SchoolDTO> schoolDTOList = JacksonUtils.convertList(schoolDOS, SchoolDTO.class);
        return schoolDTOList;
    }

    @Override
    public List<SchoolDTO> selectListByCity(String city) {
        List<SchoolDO> schoolDOS = schoolMapper.selectListByCity(city);
        List<SchoolDTO> schoolDTOList = JacksonUtils.convertList(schoolDOS, SchoolDTO.class);
        return schoolDTOList;
    }

    @Override
    public boolean update(SchoolDTO schoolDTO) {
        return schoolMapper.updateById(JacksonUtils.convert(schoolDTO,SchoolDO.class))>0;
    }
}
